home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / diskBoot.OpenProm / sun4c.md / RCS / start.s,v < prev   
Encoding:
Text File  |  1991-09-01  |  2.5 KB  |  122 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @! @;
  7.  
  8.  
  9. 1.1
  10. date     91.09.01.16.48.45;  author dlong;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @sun4c version
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @!
  27. ! The following variable MUST be the first thing in this
  28. ! file, as its position marks the beginning of small data
  29. !
  30.     .seg    "data"
  31.     .global    _environ        ! first symbol in sdata        
  32. _environ:
  33.     .word    0
  34.  
  35.     .seg    "text"
  36.     .align    4
  37. !
  38. ! Startup code for standalone system
  39. !
  40. WINDOWSIZE = (16 * 4)
  41.  
  42.     .global    _end
  43.     .global    _edata
  44.     .global    _main
  45.     .global    __exit
  46.     .global    _Boot_Transfer
  47.     .global _romVectorPtr
  48.     .global    start
  49. start:
  50.     save    %sp, -WINDOWSIZE, %sp    ! get a new window, leave room for args
  51.     call    1f            ! get the current pc into o7
  52.     nop                ! (where entry is currently located)
  53. 1:
  54.     mov    %o7, %o0        ! save for later
  55.     sub    %o0, 4, %o0        ! point to first byte of prog
  56.     set    start+4,%o6        ! address of call instruction - above 
  57.     cmp    %o6, %o7        ! are they the same
  58.     be    go
  59.     nop
  60.     set    _edata+4, %o2        ! end of program, inclusive, except bss
  61.     set    start, %o1        ! beginning of program
  62.     sub    %o2, %o1, %o2        ! size of program
  63.     !
  64.     ! copy program where it belongs
  65.     !
  66. 2:
  67.     ld    [%o0], %o3        ! read a word
  68.     add    %o0, 4, %o0            ! point to next src word
  69.     st    %o3, [%o1]        ! write a word
  70.     subcc    %o2,4, %o2        ! check if done
  71.     bge    2b            ! if not loop
  72.     add    %o1, 4, %o1        ! delay slot, point to next dest word
  73.     
  74.     set    go, %g1        ! now that it is relocated, jump to it
  75.     jmp    %g1
  76.     nop
  77.     ! program is now relocated
  78. go:
  79.     ! we should turn on cache at least by now
  80.     set    _romVectorPtr, %o2
  81.     st    %i0, [%o2]
  82.     set    _end+4, %o2        ! end of bss
  83.     set    _edata, %o0        ! beginning of bss
  84.     sub    %o2, %o0, %o2        ! size of bss
  85.     ! zero the bss
  86. 1:
  87.     subcc    %o2,1,%o2            ! loop to zero bss
  88.     st    %g0, [%o0]
  89.     bnz    1b
  90.     add    %o0, 4, %o0
  91.  
  92.     ! general startup code
  93.     set    (_environ+0x1000), %g7    ! 1st global register (etext + 4K)
  94.     set    0x2000, %g6        ! 8k
  95.     add    %g7, %g6, %g6        ! 2nd global register (1st global + 8K)
  96.     ld    [%sp + WINDOWSIZE], %o0    ! argc
  97.     add    %sp, WINDOWSIZE + 4, %o1! argv
  98.     sll    %o0, 2, %o2        ! argc * sizeof (int)
  99.     add    %o2, 4, %o2        ! skip 0 at end of arg ptrs
  100.     add    %o1, %o2, %o2        ! environ ptr
  101.     call    _main
  102.     st    %o2, [%g7 + -0x1000]    ! store 1st word of sdata %ad(_environ)
  103.     nop
  104. #ifdef notdef
  105.     call    _exit            ! exit(0)
  106. #endif
  107.     mov    0, %o0            ! delay slot
  108. __exit:
  109.     ret                ! ret to prom
  110.     restore
  111.  
  112. _Boot_Transfer:
  113.         mov     %o0, %g1
  114.         mov     %o1, %i0                ! preserve some arguments
  115.         mov     %o2, %i1                ! preserve some arguments
  116.         jmp     %g1
  117.         restore
  118.  
  119. _romVectorPtr:
  120.     .word    0
  121. @
  122.